import React, { useState } from 'react'
import Switch from 'react-switch'
import './index.scss'

export default function SwitchItem(props) {
  let { classNames, onClickHandle, checked } = props
  if (checked !== false) checked = true
  const [checked1, setChecked1] = useState(checked)
  const onChange = () => {
    setChecked1(!checked1)
    onClickHandle(!checked1)
  }

  return (
    <>
      <li className={classNames + ' SwitchItm_li'}>
        <strong>{props.children}</strong>
        <Switch checked={checked1} onColor='#6CB6FF' size='large' onChange={onChange} uncheckedIcon={false} checkedIcon={false} height={40} width={85} />
      </li>
    </>
  )
}

